package thread.exercise;

import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-03-07
 * Time:22:35
 */
public class Exercise3 {
    public static void main(String[] args) {
        new A().start();
        new B().start();
    }
}

class A extends Thread {
    static boolean flag = true;
    @Override
    public void run() {
        while (flag) {
            System.out.println(new Random().nextInt(101));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

class B extends Thread {
    @Override
    public void run() {
        while (true) {
            Scanner scanner = new Scanner(System.in);
            char ch = scanner.next().toUpperCase().charAt(0);
            if (ch == 'Q') {
                A.flag = false;
                break;
            }
        }
    }
}
